package game.players.user;

import com.uqbar.vainilla.appearances.Animation;
import com.uqbar.vainilla.appearances.Sprite;

import game.players.SoccerPlayer;
import game.players.states.ShootingPlayer;
import game.players.user.movements.WithoutBallStationaryUser;
import game.soccerField.Arc;

public class ShootingUserPlayer extends ShootingPlayer {
	
	private double direction;

	public ShootingUserPlayer(SoccerPlayer player, double direction) {
		super(player);
		this.setDirection(direction);
		
		player.setAppearance(new Animation(0.3,
				Sprite.fromImage("/images/goal3_tiro2.png").crop(0, 2, 57, 65).scale(1.5),
				Sprite.fromImage("/images/goal3_tiro2.png").crop(83, 0, 37, 65).scale(1.5),
				Sprite.fromImage("/images/goal3_tiro2.png").crop(143, 0, 51, 65).scale(1.5)
				));
	}
	
	@Override
	protected void executeShoot() {
		Arc arc = this.getPlayer().getRivalArc();
		double i = arc.getX() - this.getPlayer().getX();
		double j = arc.getY() + this.getDirection();
		
		this.getSoccerBall().roll(SPEED, i, j);
		this.getPlayer().setState(new WithoutBallStationaryUser(this.getPlayer()));
	}

	@Override
	public void loseTheBall() {
		this.getTimer().cancel();
		this.getPlayer().setState(new BeatenUserPlayer(this.getPlayer(), this.isRight()));
	}
	
	@Override
	public boolean isRight() {
		return true;
	}
	
	
	
	
	

	public double getDirection() {
		return direction;
	}

	public void setDirection(double direction) {
		this.direction = direction;
	}

}
